package com.zdxlz.fcmp.upms.api.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdxlz.fcmp.upms.api.dto.SystemLogReqDto;
import com.zdxlz.fcmp.upms.api.entity.SystemExceptionLog;
import com.zdxlz.fcmp.upms.api.mapper.SystemExceptionLogMapper;
import com.zdxlz.fcmp.upms.api.service.ISystemExceptionLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
 
/**
 * 系统异常日志记录表(SystemExceptionLog)表服务实现类
 *
 * @author makejava
 * @since 2025-03-18 09:51:08
 */
@Service
public class SystemExceptionLogServiceImpl<T> extends ServiceImpl<SystemExceptionLogMapper, SystemExceptionLog> implements ISystemExceptionLogService<T> {
 
   /**
    * 分页查询数据
    */
    @Override
    public Page<T> selectSystemExceptionLog(Page<SystemExceptionLog> page, SystemLogReqDto dto){
        LambdaQueryWrapper<SystemExceptionLog> queryWrapper = new LambdaQueryWrapper<>();
        if (ObjectUtil.isNotEmpty(dto)) {
            queryWrapper.eq(StrUtil.isNotBlank(dto.mobile()), SystemExceptionLog::getExcpMobile, dto.mobile());
        }
        return ((Page<T>) baseMapper.selectPage(page, queryWrapper));
    }
    
   /**
    * 新增一条数据
    */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertSystemExceptionLog(SystemExceptionLog entity){
        baseMapper.insert(entity);
        return true;
    }
    
   /**
    * 通过ID更新一条数据
    */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateSystemExceptionLog(SystemExceptionLog entity){
        baseMapper.updateById(entity);
        return true;
    }
    
   /**
    * 通过ID删除一条或多条数据
    */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteSystemExceptionLog(List<Integer> ids){
    baseMapper.deleteByIds(ids);
        return true;
    }
}
